package com.ruoyi.web.controller.wq;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wq.domain.WqUserRecord;
import com.ruoyi.wq.service.IWqUserRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.service.UserRecordService;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 用户信息审核Controller
 * 
 * @author ruoyi
 * @date 2023-11-08
 */
@RestController
@RequestMapping("/wq/userRecord")
public class WqUserRecordController extends BaseController {

    @Autowired
    private IWqUserRecordService wqUserRecordService;
    
    @Autowired
    private UserRecordService userRecordService;

    /**
     * 查询用户信息审核列表
     */
    @PreAuthorize("@ss.hasPermi('wq:userRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(WqUserRecord wqUserRecord)
    {
        startPage();
        List<WqUserRecord> list = wqUserRecordService.selectWqUserRecordList(wqUserRecord);
        return getDataTable(list);
    }

    /**
     * 导出用户信息审核列表
     */
    @PreAuthorize("@ss.hasPermi('wq:userRecord:export')")
    @Log(title = "用户信息审核", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WqUserRecord wqUserRecord)
    {
        List<WqUserRecord> list = wqUserRecordService.selectWqUserRecordList(wqUserRecord);
        ExcelUtil<WqUserRecord> util = new ExcelUtil<WqUserRecord>(WqUserRecord.class);
        util.exportExcel(response, list, "用户信息审核数据");
    }

    /**
     * 获取用户信息审核详细信息
     */
    @GetMapping(value = "/getInfo")
    public AjaxResult getInfo() {
        return AjaxResult.success(userRecordService.getUserRecordByUserId());
    }

    /**
     * 新增用户信息审核
     */
    @PreAuthorize("@ss.hasPermi('wq:userRecord:add')")
    @Log(title = "用户信息审核", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WqUserRecord wqUserRecord)
    {
        return toAjax(wqUserRecordService.insertWqUserRecord(wqUserRecord));
    }

    /**
     * 修改用户信息审核
     */
    @RepeatSubmit
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody WqUserRecord wqUserRecord) {
        return AjaxResult.success(userRecordService.updateRecord(wqUserRecord));
    }

    /**
     * 删除用户信息审核
     */
    @PreAuthorize("@ss.hasPermi('wq:userRecord:remove')")
    @Log(title = "用户信息审核", businessType = BusinessType.DELETE)
	@DeleteMapping("/{userIds}")
    public AjaxResult remove(@PathVariable Long[] userIds)
    {
        return toAjax(wqUserRecordService.deleteWqUserRecordByUserIds(userIds));
    }
}
